package com.example.delivery.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.delivery.pojo.Order;
import com.example.delivery.service.OrderService;
import com.example.delivery.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author huber
* @description 针对表【order】的数据库操作Service实现
* @createDate 2025-03-18 13:29:36
*/
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order>
    implements OrderService{

    @Autowired
    private OrderMapper orderMapper;
    @Override
    public Order createOrder(Order order) {
        orderMapper.insert(order);
        return order;
    }

    @Override
    public List<Order> findAllByUserId(Integer id) {
        List<Order> ordersList = orderMapper.findAllOrdersByUserId(id);
        return ordersList;
    }

    @Override
    public void updateOrderStatus(Order order) {
        orderMapper.updateById(order);
    }

    @Override
    public Order findById(Integer id) {
       return  orderMapper.selectById(id);
    }
}




